/*
 * PropertyGetter.java    ver   24/ott/2009
 *
 * Copyright (c) 2009 mentalsmash.org
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * The use of the Apache License does not indicate that this project is
 * affiliated with the Apache Software Foundation.
 */
package org.mentalsmash.tazio.transactions;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Mark a method as the <i>getter</i> for a transactional property.
 * <p>
 * The annotated method should have no business logic other then getting the
 * internal status of the object and returning it as return value. That is
 * because <i>Tazio</i> uses the returned value as the actual value ofthe
 * property
 * </p>
 * <p>
 * A <tt>PropertyGetter</tt> marked method must always be accompanied by a
 * {@link PropertySetter} marked method having the same
 * <code>propertyValue</code>
 * </p>
 * <p>
 * An example of how a <i>getter</i> method of a property should look like is
 * the following: <br>
 * 
 * <pre>
 *   &#064;TransactionalObject
 *   class User implements Serializable {
 *   	private String username;
 *      ... //your stuff
 *      
 *      &#064;PropertySetter(propertyName = "username")
 *      public void setUsername(String username) {
 *        this.username = username;
 *      }
 *      
 *      &#064;PropertyGetter(propertyName = "username")
 *      public void getUsername(String username) {
 *        return this.username;	
 *      }
 *      
 *      ... //other properties and other stuff
 *   
 *   }
 * 
 * </pre>
 * 
 * </p>
 * 
 * @version 0.0.1 24/ott/2009
 * @author Andrea Reale <andrea.reale@gmail.com>
 * @see PropertySetter
 * @see Transactional
 */
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface PropertyGetter {
    /**
     * @return the name of the property for which the annotated method is the
     *         getter
     */
    String propertyName();

    /**
     * Tells whether the given property is a readonly property, i.e. wheter it
     * provides or not a {@link PropertySetter}
     * 
     * @return
     */
    boolean readOnly() default false;
}
